Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Prefbar new button

30 views
Skip to first unread message

Eustace

unread,
Dec 24, 2009, 12:53:42 PM12/24/09
to
I want to create a Prefbar button to toggle between

browser.display.use_document_colors and
browser.display.use_system_colors.

So in the Preferences Toolbar I clicked the button New Item, and in the
dropdown list of the dialog I chose button.

In the Common tab I am not sure what I should put in Id:. I try
webColors, the same as in Label.

The onClick tab seems to be the most crucial. I tried this, just in case:

if (browser.display.use_document_colors==true) {
browser.display.use_document_colors=false;
browser.display.use_system_colors=true;
else {
browser.display.use_document_colors=true;
browser.display.use_system_colors=false;
}

but I wasn't lucky enough. The Init-function seems superfluous, no other
buttons use it.

How can I make the button do what I want it to do?

Thanks,

emf

--
It ain't THAT, babe! - A radical reinterpretation
https://files.nyu.edu/emf202/public/bd/itaintmebabe.html

David E. Ross

unread,
Dec 24, 2009, 2:06:46 PM12/24/09
to
On 12/24/2009 9:53 AM, Eustace wrote:
> I want to create a Prefbar button to toggle between
>
> browser.display.use_document_colors and
> browser.display.use_system_colors.
>
> So in the Preferences Toolbar I clicked the button New Item, and in the
> dropdown list of the dialog I chose button.
>
> In the Common tab I am not sure what I should put in Id:. I try
> webColors, the same as in Label.
>
> The onClick tab seems to be the most crucial. I tried this, just in case:
>
> if (browser.display.use_document_colors==true) {
> browser.display.use_document_colors=false;
> browser.display.use_system_colors=true;
> else {
> browser.display.use_document_colors=true;
> browser.display.use_system_colors=false;
> }
>
> but I wasn't lucky enough. The Init-function seems superfluous, no other
> buttons use it.
>
> How can I make the button do what I want it to do?
>
> Thanks,
>
> emf

The two preference variables are NOT opposites of each other.

browser.display.use_document_colors controls whether a Web page
specifies its own colors or your default colors are used.

If browser.display.use_system_colors is true, then your default colors
are the colors specified by your operating system. If it is false, your
default colors are those specified by your browser, which can be
modified by setting other preferences.

I think you might be able to accomplish what you want by setting default
colors equal or close to your system's defaults. Then, instead of a
button, use the existing PrefBar "Colors" checkbox to toggle
browser.display.use_document_colors.

--
David E. Ross
<http://www.rossde.com/>

Go to Mozdev at <http://www.mozdev.org/> for quick access to
extensions for Firefox, Thunderbird, SeaMonkey, and other
Mozilla-related applications. You can access Mozdev much
more quickly than you can Mozilla Add-Ons.

Eustace

unread,
Dec 24, 2009, 2:35:53 PM12/24/09
to

My problem is that while I have white on blue system colors in my
system, I had to assign black on white FF colors in order to correct
webpages that do not specify font color or background color, assuming
that everybody uses black on white system colors.

At this point, I have 2 checkboxes on the Prefbar, the document_colors
and the system_colors, and I have to check the one and uncheck the other
according to my needs. If I had a button I am describing, this process
would be simpler.

Unchecking both assigns the FF colors (black on white) which I do not
like. Checking both, most webpages look OK, but in some you cannot see
what is written, since the font color is not specified and the white
system font color is used on white background, or, more rarely, the
background color is not specified, and the blue system background color
is used with black font color.

So my question remains: How can make the button toggle between
system_colors and document_colors?

David E. Ross

unread,
Dec 24, 2009, 4:59:44 PM12/24/09
to

NOTE: That is not a valid assumption. I believe the usual default
background is grey.


> At this point, I have 2 checkboxes on the Prefbar, the document_colors
> and the system_colors, and I have to check the one and uncheck the other
> according to my needs. If I had a button I am describing, this process
> would be simpler.
>
> Unchecking both assigns the FF colors (black on white) which I do not
> like. Checking both, most webpages look OK, but in some you cannot see
> what is written, since the font color is not specified and the white
> system font color is used on white background, or, more rarely, the
> background color is not specified, and the blue system background color
> is used with black font color.
>
> So my question remains: How can make the button toggle between
> system_colors and document_colors?
>
> emf
>

Okay. Then try creating an Extlist. This is a form of menu list that
allows more extensive operations than merely changing one preference
variable. View the installed User Agent menu as an example; view it as
if you were going to edit it.

You can have the following options if you wish:
Browser Default
Web Page
System Default (Neither Browser Nor Web)
Both Browser and Web

By the way, I found that a white background makes my eyes tired. I
default to a pale green background (#D2EDD1) with black text (#000000).
If I find a page that has a bad text/background color combination, I
merely uncheck the Color checkbox on the PrefBar tool bar.

Eustace

unread,
Dec 24, 2009, 11:17:41 PM12/24/09
to

OK. I meant dark color on light color.

>
>> At this point, I have 2 checkboxes on the Prefbar, the document_colors
>> and the system_colors, and I have to check the one and uncheck the other
>> according to my needs. If I had a button I am describing, this process
>> would be simpler.
>>
>> Unchecking both assigns the FF colors (black on white) which I do not
>> like. Checking both, most webpages look OK, but in some you cannot see
>> what is written, since the font color is not specified and the white
>> system font color is used on white background, or, more rarely, the
>> background color is not specified, and the blue system background color
>> is used with black font color.
>>
>> So my question remains: How can make the button toggle between
>> system_colors and document_colors?
>>
>> emf
>>
>
> Okay. Then try creating an Extlist. This is a form of menu list that
> allows more extensive operations than merely changing one preference
> variable. View the installed User Agent menu as an example; view it as
> if you were going to edit it.

I am afraid I need a link to information on creating Extlists, though I
am going to check User Agent more carefully again.

> You can have the following options if you wish:
> Browser Default
> Web Page
> System Default (Neither Browser Nor Web)
> Both Browser and Web
>
> By the way, I found that a white background makes my eyes tired. I

> default to a pale green (#D2EDD1) with black text (#000000).


> If I find a page that has a bad text/background color combination, I
> merely uncheck the Color checkbox on the PrefBar tool bar.

What I do is either (a) check a bookmarklet on the bookmarks bar to turn
the colors of the current tab white on blue, or (b) uncheck the
(doc)colors and check the (sys)colors on the Prefbar which has a similar
effect but on all tabs. Option b implies 4 clicks (including turning the
(web)colors back on), so it's useful when having to read several similar
pages, i.e. several massages of a forum, and it leaves the possibility
of turning the documents colors back on without having to redownload the
pages. If the 4 clicks in checkboxes were reduced to 2 on a button, it
would be a lot better.

I suspect other users of the Prefbar would find such a button useful.

emf

--
Date Calculator with all-purpose JS code
https://files.nyu.edu/emf202/public/js/datecalc.html

David E. Ross

unread,
Dec 24, 2009, 11:42:10 PM12/24/09
to
On 12/24/2009 8:17 PM, Eustace wrote [in part]:

> On 2009-12-24 16:59 I previously wrote [also in part]:
>> Okay. Then try creating an Extlist. This is a form of menu list that
>> allows more extensive operations than merely changing one preference
>> variable. View the installed User Agent menu as an example; view it as
>> if you were going to edit it.
>
> I am afraid I need a link to information on creating Extlists, though I
> am going to check User Agent more carefully again.

I'm sorry, but I don't have any further information. I haven't tried
creating an Exlist on my own. I've only updated the values in the UA
String Exlist.

Try contacting Aaron Andersen (current PrefBar developer) or Manuel
Reimer (PrefBar "owner"). See <http://prefbar.mozdev.org/members.html>
for contact information.

Eustace

unread,
Dec 24, 2009, 11:50:22 PM12/24/09
to
On 2009-12-24 23:42 David E. Ross wrote:
> On 12/24/2009 8:17 PM, Eustace wrote [in part]:
>> On 2009-12-24 16:59 I previously wrote [also in part]:
>>> Okay. Then try creating an Extlist. This is a form of menu list that
>>> allows more extensive operations than merely changing one preference
>>> variable. View the installed User Agent menu as an example; view it as
>>> if you were going to edit it.
>> I am afraid I need a link to information on creating Extlists, though I
>> am going to check User Agent more carefully again.
>
> I'm sorry, but I don't have any further information. I haven't tried
> creating an Exlist on my own. I've only updated the values in the UA
> String Exlist.
>
> Try contacting Aaron Andersen (current PrefBar developer) or Manuel
> Reimer (PrefBar "owner"). See <http://prefbar.mozdev.org/members.html>
> for contact information.

I may have to. BTW, a simpler solution to my problem would be to have 2
buttons, 1 turning system_colors on and document_colors off and the
other doing the opposite, instead of having 1 toggling between them.

Manuel Reimer

unread,
Dec 25, 2009, 9:44:41 AM12/25/09
to
Eustace wrote:
> I may have to. BTW, a simpler solution to my problem would be to have 2
> buttons, 1 turning system_colors on and document_colors off and the
> other doing the opposite, instead of having 1 toggling between them.

You need a *extcheck* and no *extlist*!

You don't need the Initfunction. This is only needed to initialize
global stuff. For example to hook a function in the browser, so the
button is able to do some stuff, which would be impossible otherwise.
For an example for "Initfunction" have a look at the "Referrer Spoof
Menulist" available on the "More buttons" page on prefbar.mozdev.org.
This button registers an observer in the background, so the modified
referrer can be injected into HTTP requests.

You have to fill *getfunction* and *setfunction*. In the first, you have
to assign the current value of the checkbox to the virtual variable
"value" and in the second, PrefBar prefills the variable "value" with
the checkbox value, so you may write it back to where you want it.

In short:
getfunction: Get boolean value from "somewhere" and write to variable
"value"
setfunction: Get current checkbox state (boolean) from variable "value"
and write to "somewhere"

A basic explaination of how to use this is available in the PrefBar help
system. If you need further Info, please ask.

If you manage to get this to work and want it to be listed on the
PrefBar homepage, it would help, if you try your button(s) with
SeaMonkey 2.0.1. I don't accept buttons, which only work with Firefox
and I'm too busy to add SeaMonkey support to commited buttons!

CU

Manuel

Eustace

unread,
Dec 28, 2009, 8:37:28 PM12/28/09
to

I had already myself decided that I needed an extcheck. It's a pity
there is not extbutton yet. Anyway, I do need further info, since the I
wasn't able to find specific directions. To get started trying, I would
like to know this:

What should be put in the get-function and in set-function tabs to
create an extcheck that behaves like the systemcolors?

Thanks,

Manuel Reimer

unread,
Dec 29, 2009, 8:06:45 AM12/29/09
to
Eustace wrote:
> I had already myself decided that I needed an extcheck. It's a pity
> there is not extbutton yet.

Why do you need an "extbutton"? The regular "button" already is a
"scriptable" item.

> Anyway, I do need further info, since the I
> wasn't able to find specific directions. To get started trying, I would
> like to know this:
>
> What should be put in the get-function and in set-function tabs to
> create an extcheck that behaves like the systemcolors?

"systemcolors" is a regular preference checkbox. Means, that it controls
a preference, which may also be accessible via about:config.

If you want to use a extcheck (which is a scriptable item and no
pref-controlling item), then you need to read and write the pref by
yourself. PrefBar has an API function, which helps you with this.

setfunction would be:

goPrefBar.SetPref("browser.display.use_system_colors", value);

getfunction would be:

value = goPrefBar.GetPref("browser.display.use_system_colors");

As described before, we have to work with the variable "value", which
holds the current checkbox value in the "setfunction" and has to be
filled with the value, the checkbox should be switched to, in "getfunction".

CU

Manuel

Eustace

unread,
Dec 31, 2009, 2:16:41 AM12/31/09
to

Thanks a lot. The extCheck works perfectly. Checking the "Scolors" turns
the system colors on and the document colors off and when unchecking it
vice versa. I'll be listing it in the Prefbar homepage after I play with
it a little.

Now, going back to the idea of having a button instead of a checkbox,
and since you say it is scriptable, I tried entering in the onClick tab
the following code:

============


value = goPrefBar.GetPref("browser.display.use_system_colors");

if (value==false) {
goPrefBar.SetPref("browser.display.use_system_colors", true);
goPrefBar.SetPref("browser.display.use_document_colors", false);
else {
goPrefBar.SetPref("browser.display.use_system_colors", false);
goPrefBar.SetPref("browser.display.use_document_colors", true);
}
============

but it does not work. Why?

Having 1 checkbox instead of 2 helps a lot of work. Having a button
instead of a checkbox would be a little easier to aim the pointer at!

Thanks again,

Eustace

--
The folk oratorios of Mikis Theodorakis
https://files.nyu.edu/emf202/public/mt/oratorios.html

Eustace

unread,
Dec 31, 2009, 2:29:17 AM12/31/09
to
On 2009-12-29 08:06 Manuel Reimer wrote:

A peculiar quirk: In the extcheck I have set in the Set-function tab:

goPrefBar.SetPref("browser.display.use_system_colors", value2);
goPrefBar.SetPref("browser.display.use_document_colors", value1);

and in the Get-function tab:

value1 = goPrefBar.GetPref("browser.display.use_system_colors");
value2 = goPrefBar.GetPref("browser.display.use_document_colors");

and as I said it works OK, except that the checkbox remains always
checked, except when you switch focus to another window and then you
return to FF, when it gets unchecked. Is there a way to have it get
unchecked when I click in it when it is already checked, and to have it
get checked and remain so after I return to FF from another window?

Manuel Reimer

unread,
Dec 31, 2009, 4:37:07 AM12/31/09
to
Eustace wrote:
> ============
> value = goPrefBar.GetPref("browser.display.use_system_colors");
>
> if (value==false) {
> goPrefBar.SetPref("browser.display.use_system_colors", true);
> goPrefBar.SetPref("browser.display.use_document_colors", false);
> else {
> goPrefBar.SetPref("browser.display.use_system_colors", false);
> goPrefBar.SetPref("browser.display.use_document_colors", true);
> }
> ============

"value" has to be declared, if used in a plain button, as it isn't
provided by PrefBar itself, there. If you miss this, you create a global
variable which may override stuff in the browser backend. Means, you
need a "var" in front of "value".

The big mistake, which makes this code fail, should be the missing curly
bracket before "else". You didn't close the "if" block before opening
the "else" block.

> Having 1 checkbox instead of 2 helps a lot of work. Having a button
> instead of a checkbox would be a little easier to aim the pointer at!

But the button isn't meant to be used for this. You can't see the
current status of the setting. You have to guess, which state the button
has.

It even isn't easier to aim the pointer at, as you may also just click
into the text of a checkbox. You don't have to center exactly into the
checkbox.

Why don't you just keep "use_system_colors" on "true" and only toggle
"use_document_colors"? IMHO the "use_system_colors" doesn't really do
something, if document colors are allowed.

CU

Manuel

Manuel Reimer

unread,
Dec 31, 2009, 4:48:39 AM12/31/09
to
Eustace wrote:
> A peculiar quirk: In the extcheck I have set in the Set-function tab:
>
> goPrefBar.SetPref("browser.display.use_system_colors", value2);
> goPrefBar.SetPref("browser.display.use_document_colors", value1);
>
> and in the Get-function tab:
>
> value1 = goPrefBar.GetPref("browser.display.use_system_colors");
> value2 = goPrefBar.GetPref("browser.display.use_document_colors");

That's (sorry...) *wrong*

In "getfunction", PrefBar asks "which state should the checkbox have?".
It's your job to provide the state in the "value" variable, which is
controlled by PrefBar itself.

In "setfunction", PrefBar tells "My checkbox has state ... Please do
something with it". Again, we have the state in the "value" variable,
but this time it has been prefilled by PrefBar.

PrefBar calls "getfunction" whenever it re-renders the toolbar and needs
the state of the checkboxes to prefill them correctly. Setfunction gets
called whenever the checkbox is toggled by the user.

You have to use the "value" variable without declaring it, as PrefBar
predeclared it, so it has access to its value. If you create new
variables, then you *have to* declare them with a "var" in front of it!!!

So your example could look like this:

Setfunction:

goPrefBar.SetPref("browser.display.use_system_colors", !value);
goPrefBar.SetPref("browser.display.use_document_colors", value);

Getfunction:

value = goPrefBar.GetPref("browser.display.use_document_colors");

As you see, I control two preferences, but I just return the state of
one of the two back to PrefBar.

> and as I said it works OK, except that the checkbox remains always
> checked, except when you switch focus to another window and then you
> return to FF, when it gets unchecked. Is there a way to have it get
> unchecked when I click in it when it is already checked, and to have it
> get checked and remain so after I return to FF from another window?

It's your job to tell PrefBar the state of the checkbox. That's what
"Getfunction" is meant to be used for ;-)

CU

Manuel

Eustace

unread,
Dec 31, 2009, 12:23:38 PM12/31/09
to
On 2009-12-31 04:48 Manuel Reimer wrote:
> Eustace wrote:
>> A peculiar quirk: In the extcheck I have set in the Set-function tab:
>>
>> goPrefBar.SetPref("browser.display.use_system_colors", value2);
>> goPrefBar.SetPref("browser.display.use_document_colors", value1);
>>
>> and in the Get-function tab:
>>
>> value1 = goPrefBar.GetPref("browser.display.use_system_colors");
>> value2 = goPrefBar.GetPref("browser.display.use_document_colors");
>
> That's (sorry...) *wrong*
>
> In "getfunction", PrefBar asks "which state should the checkbox have?".
> It's your job to provide the state in the "value" variable, which is
> controlled by PrefBar itself.

After reading this paragraph, and before reading the rest of the
message, I went to FF and edited the code exactly as you describe below.
I had considered it when first writing the code but had decided on the
wrong code somehow.

Thanks again,

Eustace

unread,
Dec 31, 2009, 1:12:40 PM12/31/09
to
On 2009-12-31 04:37 Manuel Reimer wrote:
> Eustace wrote:
>> ============
>> value = goPrefBar.GetPref("browser.display.use_system_colors");
>>
>> if (value==false) {
>> goPrefBar.SetPref("browser.display.use_system_colors", true);
>> goPrefBar.SetPref("browser.display.use_document_colors", false);
>> else {
>> goPrefBar.SetPref("browser.display.use_system_colors", false);
>> goPrefBar.SetPref("browser.display.use_document_colors", true);
>> }
>> ============
>
> "value" has to be declared, if used in a plain button, as it isn't
> provided by PrefBar itself, there. If you miss this, you create a global
> variable which may override stuff in the browser backend.

Oops, that's not good. I hope it can't cause permanent malfunction. It
happened that I started having some problems with the address bar at
about the same time when I was trying the code...

> Means, you need a "var" in front of "value".
>
> The big mistake, which makes this code fail, should be the missing curly
> bracket before "else". You didn't close the "if" block before opening
> the "else" block.

Of course. I should have been more careful.

>> Having 1 checkbox instead of 2 helps a lot of work. Having a button
>> instead of a checkbox would be a little easier to aim the pointer at!
>
> But the button isn't meant to be used for this. You can't see the
> current status of the setting. You have to guess, which state the button
> has.

No guessing. I just had to look at the webpage.

> It even isn't easier to aim the pointer at, as you may also just click
> into the text of a checkbox. You don't have to center exactly into the
> checkbox.

Well, there is always something new to learn with computers that was
always under your nose. Certainly, then a check box is better than the
button.

> Why don't you just keep "use_system_colors" on "true" and only toggle
> "use_document_colors"? IMHO the "use_system_colors" doesn't really do
> something, if document colors are allowed.
>
> CU
>
> Manuel

I have already explained the situation in me second post in the thread:

My system, preferred, colors are white on blue (like good old WP4.2).

My FF colors *have to be* black on white, so that they correct
webmasters that forget to assign text color (black) in all or some of
the text while assigning background color (white or similar) or, less
frequently, they assign text color (black) but forget to assign
background color (white). In either case the text in not legible when I
have both document colors and system colors on: either the text is white
on white background, or the text is black on blue background.

It follows that over here when the document colors is on the system
color have to be off. On the other hand, to use the system colors you
have to have the document colors off. Hence the necessity of my extcheck.

When I list my extcheck in the PrefBar site I'll try to explain all this
in a short paragraph to justify its existence. I imagine it all seems
rather complicated to those who have not encountered similar problems,
but there have to be a certain number of people out there with
preferences and needs similar to mine.

0 new messages